﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace Proggy.Data.Entities
{
    /// <summary>
    /// Member group
    /// </summary>
    public class Group
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public Group()
        {
            this.GroupMembers = new HashSet<GroupMember>();
            this.AllowedViewingNodes = new HashSet<PublishableNode>();
            this.AllowedEditingNodes = new HashSet<PublishableNode>();
        }

        /// <summary>
        /// Primary key
        /// </summary>
        [Key]
        public int GroupId { get; set; }

        /// <summary>
        /// The group name
        /// </summary>
        [Required(AllowEmptyStrings = false)]
        [Display(Name = "Group name")]
        [MaxLength(64)]
        public string GroupName { get; set; }

        /// <summary>
        /// The members of this group
        /// </summary>
        public virtual ICollection<GroupMember> GroupMembers { get; set; }

        public DateTime FirstCreated { get; set; }
        public string FirstCreatedUsername { get; set; }

        public DateTime LastUpdated { get; set; }
        public string LastUpdatedUsername { get; set; }

        public virtual ICollection<PublishableNode> AllowedViewingNodes { get; set; }
        public virtual ICollection<PublishableNode> AllowedEditingNodes { get; set; }
    }
}